//
//  DYSetCollectionCell.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/21.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYSetCollectionCell.h"

@interface DYSetCollectionCell ()<TZImagePickerControllerDelegate>

@property (nonatomic,strong)TZImagePickerController *imagePicker;

@end

@implementation DYSetCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)dy_initUI
{
    [super dy_initUI];
    
    self.sideMargin=BILIWIDTH(10);
    [self xhq_noneSelectionStyle];
    
    
    self.titleLabel=({
        UILabel *label=[Utils labelWithTitleFontSize:12 textColor:[UIColor xhq_content] alignment:0];
        label;
    });
    
    self.showImageView = ({
        UIImageView *imageView=[Utils imageViewWithImage:IMG(@"img_upload")];
        imageView.contentMode=UIViewContentModeScaleAspectFill;
        imageView.userInteractionEnabled=YES;
        imageView.clipsToBounds=YES;
        imageView;
    });
    
    self.tipLabel =({
        UILabel *label=[Utils labelWithTitleFontSize:12 textColor:[UIColor xhq_content] alignment:0];
        label.text=@"营业执照地址应和店铺地址一致，如不一致，请提出理由，否则不予通过";
        label;
    });
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.showImageView];
    [self addSubview:self.tipLabel];
    
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.top.equalTo(BILIHEIGHT(10));
    }];
    
    [self.showImageView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.bottom).offset(BILIHEIGHT(5));
        make.left.equalTo(self.titleLabel);
        make.size.equalTo(CGSizeMake(BILIHEIGHT(65), BILIHEIGHT(65)));
    }];
    
    [self.tipLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.showImageView.right).offset(BILIWIDTH(10));
        make.centerY.equalTo(self.showImageView);
        make.right.equalTo(BILIWIDTH(-10));
    }];
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(addPhoto)];
    [self.showImageView addGestureRecognizer:tap];
    
    [self.tipLabel xhq_lineSpace:BILIHEIGHT(3)];
}
-(void)addPhoto
{
    @weakify(self);
    [[DYAppCommon getCurrentVC] presentViewController:self.imagePicker animated:YES completion:nil];
    [self.imagePicker setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
        @strongify(self);
        self.showImageView.image=photos.firstObject;
    }];
}
-(TZImagePickerController *)imagePicker
{
    if (!_imagePicker) {
        _imagePicker=[[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self];
        _imagePicker.preferredLanguage=@"zh-Hans";
        _imagePicker.allowPickingVideo=NO;
        _imagePicker.naviBgColor=[UIColor whiteColor];
        _imagePicker.naviTitleColor=[UIColor xhq_aTitle];
        _imagePicker.barItemTextColor=[UIColor xhq_aTitle];
        _imagePicker.showSelectBtn=YES;
    }
    return _imagePicker;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end


@implementation DYSetCollectionCodeCell

-(void)dy_initUI
{
    [super dy_initUI];
    
    self.sideMargin=BILIWIDTH(10);
    [self xhq_noneSelectionStyle];
    
    self.titleLabel=({
        UILabel *label=[Utils labelWithTitleFontSize:12 textColor:[UIColor xhq_content] alignment:0];
        label.text=@"验证码";
        label;
    });
    
    self.textField = ({
        UITextField *text=[[UITextField alloc]init];
        text.font=kFont(14);
        text.placeholder=@"请输入验证码";
        [text setValue:[UIColor xhq_assist] forKeyPath:@"_placeholderLabel.textColor"];
        text.autocorrectionType = UITextAutocorrectionTypeNo;
        [text setNumbersKeyboard];
        text;
    });
    
    self.codeButton=({
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:WhiteColor action:@selector(codeButtonClick) target:self title:@"获取验证码" image:nil font:15 textColor:[UIColor xhq_base]];
        button;
    });
    
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.textField];
    [self addSubview:self.codeButton];
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.top.equalTo(BILIHEIGHT(10));
    }];
    
    [self.textField makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self);
        make.height.equalTo(BILIHEIGHT(30));
        make.left.equalTo(BILIWIDTH(10));
        make.right.equalTo(BILIWIDTH(-130));
    }];
    
    [self.codeButton makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(BILIWIDTH(-10));
        make.top.equalTo(BILIHEIGHT(15));
        make.height.equalTo(BILIHEIGHT(40));
    }];

}

-(void)codeButtonClick
{
    
}

@end
